//
// Created by wangxiyue on 2019/9/20.
//
#include <stdio.h>

void print(int *a, int length) {

    for (int i = 0; i < length; i++) {
        printf("%d", a[i]);
    }
    printf("\n");
}


int *select_sort(int *a, int length) {

    for (int i = 0; i < length; i++) {
        int min_value_index = i;
        for (int j = i + 1; j < length; j++) {
            // select the min value index and record it
            if (a[min_value_index] > a[j]) {
                min_value_index = j;
            }
        }
        if (min_value_index != i) {
            int temp = a[min_value_index];
            a[min_value_index] = a[i];
            a[i] = temp;
        }
        print(a, length);
    }
    return a;
}


int main() {

    int a[] = {5, 1, 3, 2, 4, 0};
    select_sort(a, sizeof(a) / sizeof(int));
    return 0;
}